{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <!-- 表单头部 -->
                <div class="card-header">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fas fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="card-body">
                        <div class="form-group row rowSelect">
    <label for="project_id" class="col-sm-2 col-form-label">项目</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="project_id" id="project_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择项目">
            <option value=""></option>
            {foreach name='project_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.project_id==$item.id}selected{/if}>
        {$item.title}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#project_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowSelect">
    <label for="project_log_id" class="col-sm-2 col-form-label">竞价记录</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="project_log_id" id="project_log_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择竞价记录">
            <option value=""></option>
            {foreach name='project_log_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.project_log_id==$item.id}selected{/if}>
        {$item.id}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#project_log_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowSelect">
    <label for="company_id" class="col-sm-2 col-form-label"></label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="company_id" id="company_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择">
            <option value=""></option>
            {foreach name='company_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.company_id==$item.id}selected{/if}>
        {$item.name}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#company_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowSelect">
    <label for="admin_user_id" class="col-sm-2 col-form-label">评分员</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="admin_user_id" id="admin_user_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择评分员">
            <option value=""></option>
            {foreach name='admin_user_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.admin_user_id==$item.id}selected{/if}>
        {$item.username}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#admin_user_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowEditor">
    <label for="detail" class="col-sm-2 col-form-label">详情</label>
        <div class="col-sm-10">
            <div id="detailEditor">{$data.detail|raw|default='<p></p>'}</div>
            <textarea id="detail" name="detail" style="display: none">{$data.detail|raw|default=''}</textarea>
        </div>
    <script>
        var E = E||window.wangEditor;
        if(editor_detail!==undefined){
            editor_detail.destroy();
        }
        var editor_detail = new E('#detailEditor');
        editor_detail.config.zIndex=1000;
        editor_detail.config.uploadImgServer = editorUploadUrl;
        editor_detail.config.uploadFileName = 'file';
        editor_detail.create();
        editor_detail.config.onchange = function (newHtml) {
            $('#detail').val(newHtml);
        };
</script>
</div>

                    </div>
                    <!-- 表单底部 -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-2">
                            </div>

                            <div class="col-sm-10 col-md-4 formInputDiv">

                                <div class="btn-group">
                                    <button type="submit" class="btn btn-sm btn-primary dataFormSubmit">
                                        保 存
                                    </button>
                                </div>
                                <div class="btn-group">
                                    <button type="reset" class="btn btn-sm btn-default dataFormReset">
                                        重 置
                                    </button>
                                </div>

                                {if !isset($data)}
                                <div class="btn-group float-right createContinueDiv">
                                    <input type="checkbox" class="form-check-input" value="1" id="_create" name="_create" title="继续添加数据">
                                    <label class="form-check-label" for="_create">继续添加</label>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
                'project_id': {
                required: true,

    },
    'project_log_id': {
                required: true,

    },
    'company_id': {
                required: true,

    },
    'admin_user_id': {
                required: true,

    },
    'detail': {
                required: true,

    },

        },
        messages: {
                'project_id': {
               required: "项目不能为空",

    },
    'project_log_id': {
               required: "竞价记录不能为空",

    },
    'company_id': {
               required: "不能为空",

    },
    'admin_user_id': {
               required: "评分员不能为空",

    },
    'detail': {
               required: "详情不能为空",

    },

        }
    });
</script>
{/block}